﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Bymed.SpineScan.WPF.Model;
using Bymed.SpineScan.Service.Shared;

namespace Bymed.SpineScan.WPF.ViewModel.TestItemViewModel
{
    public class BodyBalanceTestItemViewModel : SingleTestItemViewModel
    {
        /// <summary>
        /// Initializes a new instance of the TestItemPelvicBalanceViewModel class.
        /// </summary>
        public BodyBalanceTestItemViewModel(IDataService dataService)
            : base(dataService) { }

        /// <summary>
        /// Set the value for FormattedTestResult property.
        /// </summary>
        public override void SetFormattedTestResult()
        {
            if (FirstTestResult.HasValue || SecondTestResult.HasValue)
            {
                if (FirstTestResult == 0 && SecondTestResult == 0)
                {
                    FormattedTestResult = "0°";
                }
                else if (FirstTestResult > 0)
                {
                    FormattedTestResult = string.Format("{0}{1}°",
                    FirstTestResultLabel, FirstTestResult);
                }
                else if (SecondTestResult > 0)
                {
                    FormattedTestResult = string.Format("{0}{1}°",
                    SecondTestResultLabel, SecondTestResult);
                }
            }
        }

        /// <summary>
        /// Check if current test is finished.
        /// </summary>
        /// <returns>True means finished. False means not.</returns>
        public override bool CheckIfTestFinished()
        {
            if (!FirstTestResult.HasValue && !SecondTestResult.HasValue)
            {
                return false;
            }
            else
            {
                return true;
            }
        }

        protected override void InitializeParameters()
        {
            ReverseBackgroundColor = true;
        }
    }
}
